<template>
	<view>
		<simple-toolbar :title="$t('pool.walletPool.walletPool')">
			<view class="update">
				<view class="button" @click="editWalletPool(1)">
					<image src="../../../static/create.png"></image>
					<text>{{ $t('pool.walletPool.newWalletPool') }}</text>
				</view>
			</view>
		</simple-toolbar>

		<view class="pad-base table">
			<el-table :data="listData" style="width: 100%">
				<el-table-column align='center' prop="wallet" :label="$t('pool.walletPool.wallet')"></el-table-column>
				<el-table-column align='center' prop="coin_name" :label="$t('wallet.wallet.coin')"></el-table-column>
				<el-table-column align='center' prop="wallet_name" :label="$t('pool.walletPool.wallet_name')"></el-table-column>
				<el-table-column align='center' prop="wallet_type" :label="$t('pool.walletPool.wallet_type')">
					<template slot-scope="scope">
						<text>{{ scope.row.wallet_type ? $t('pool.walletPool.savings') : $t('pool.walletPool.pool') }}</text>
					</template>
				</el-table-column>
				<el-table-column align='center' prop="creater" :label="$t('pool.walletPool.create_by')"></el-table-column>
				<el-table-column align='center' prop="create_time" :label="$t('pool.walletPool.create_time')"></el-table-column>
				<el-table-column align='center' :label="$t('pool.walletPool.is_active')">
					<template slot-scope="scope">
						<text>{{ scope.row.is_active ? $t('pool.walletPool.effective') : $t('pool.walletPool.invalid') }}</text>
					</template>
				</el-table-column>
				<el-table-column align='center' :label="$t('pool.walletPool.operation')" width="80">
					<template slot-scope="scope">
						<el-button @click="editWalletPool(2, scope.row)" type="text" size="small">
							{{ $t('pool.walletPool.modify') }}
						</el-button>
					</template>
				</el-table-column>
			</el-table>
		</view>
	</view>
</template>

<script>
	import {
		walletPool
	} from "../../../js_sdk/uni-admin/assetPool.js"

	export default {
		data() {
			return {
				listData: []
			}
		},
		methods: {
			editWalletPool(state, row) {
				uni.navigateTo({
					url: `./editWalletPool?state=${state}&data=${encodeURIComponent(JSON.stringify(row))}`
				})
			},
			async walletPool() {
				let res = await walletPool()
				this.listData = res.data
				this.listData.forEach(item => {
					item.create_time = this.$utils.formatDate(item.create_time)
				})
			}
		},
		onShow() {
			this.walletPool()
		}
	}
</script>

<style>

</style>
